﻿<cms-page-header cms-title="{{vm.pageTemplate.name}}"
                 cms-parent-title="Page Templates"></cms-page-header>

<cms-form cms-name="mainForm"
          cms-edit-mode="vm.editMode"
          ng-submit="vm.save()"
          cms-loading="vm.formLoadState.isLoading">

    <!-- Scrollable content area -->
    <cms-page-body cms-content-type="form"
                   cms-has-actions="false">

        <cms-form-status></cms-form-status>

        <!--MAIN-->
        <cms-form-section cms-title="Main">

            <cms-form-field-text cms-title="Name"
                                 cms-model="vm.command.name"
                                 maxlength="100"
                                 required></cms-form-field-text>

            <cms-form-field-text-area cms-title="Description"
                                      cms-model="vm.command.description"></cms-form-field-text-area>

            <cms-form-field-readonly cms-title="File path"
                                     cms-model="vm.pageTemplate.fullPath"></cms-form-field-readonly>

            <cms-form-field-container cms-title="Page Type">
                <span>{{vm.pageTemplate.pageType == 'CustomEntityDetails' ? vm.pageTemplate.customEntityDefinition.name + ' Details' : vm.pageTemplate.pageType}}</span>
            </cms-form-field-container>

            <cms-form-field-readonly cms-title="Model Type"
                                     cms-model="vm.pageTemplate.customEntityModelType"
                                     ng-if="vm.pageTemplate.pageType == 'CustomEntityDetails'"></cms-form-field-readonly>

            <cms-form-field-container cms-title="Num Pages">
                <a href="{{vm.urlLibrary.pageList({ pageTemplateId: vm.pageTemplate.pageTemplateId })}}">{{::vm.pageTemplate.numPages}}</a>
            </cms-form-field-container>

        </cms-form-section>

        <!--REGIONS-->

        <cms-form-section cms-title="Regions">

            <div class="control-group">
                <div class="control-group-area">
                    <cms-table-container>
                        <table>
                            <thead>
                                <tr>
                                    <th>Name</th>
                                    <th ng-if="vm.pageTemplate.customEntityDefinition">Entity</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ng-if="!vm.pageTemplate.regions.length">
                                    <td colspan="100" class="empty">None.</td>
                                </tr>
                                <tr ng-repeat="region in vm.pageTemplate.regions">
                                    <td>{{::region.name}}</td>
                                    <td ng-if="vm.pageTemplate.customEntityDefinition">
                                        <span ng-if="::region.isCustomEntityRegion">{{::vm.pageTemplate.customEntityDefinition.name}}</span>
                                        <span ng-if="::!region.isCustomEntityRegion">Page</span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </cms-table-container>
                </div>

            </div>

        </cms-form-section>

    </cms-page-body>

</cms-form>